<!doctype html>
<html lang="zh-cmn-Hans">
<head>
	<meta charset="UTF-8">
	<title>再生资源</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/backend_/css/font.css" />
	<link rel="stylesheet" href="/backend_/css/xadmin.css" />
	<link rel="stylesheet" href="/backend_/plugin/layui/css/layui.css" />
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/backend_/plugin/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/backend_/javascript/xadmin.js"></script>
    <script type="text/javascript" src="/backend_/javascript/tool.js"></script>
</head>
<body class="login-bg">
    <div class="login layui-anim layui-anim-up">
        <div class="message">再生资源 - 管理登录</div>
        <div id="darkbannerwrap"></div>
        <form class="layui-form">
            <input name="username" placeholder="用户名" type="text" maxlength="20" class="layui-input" lay-verify="required|normal" autocomplete="off" />
            <hr class="hr15">
            <input name="password" placeholder="密码" type="password" maxlength="20" class="layui-input" lay-verify="required|normal" autocomplete="off" />
            <hr class="hr15" />
			<div>
				<input style="display:inline-block;width:40%;" name="verify" placeholder="验证码" type="text" maxlength="5" class="layui-input" lay-verify="required|normal" autocomplete="off" />
				<img id='verify' style="display:inline-block;width:200px;height:50px;border-radius:4px;" src="{$captcha}" />
			</div>
            <hr class="hr15" />
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit" />
            <hr class="hr20" />
        </form>
    </div>
    <script type="text/javascript">
		
		layui.use('form', function(){
			
			layui.form.verify({
				normal: function(value, item) {
					if(true !== /^[a-zA-z0-9]{1,20}$/.test(value)){
						return '只能输入字母及数字';
					};
				}
			});
			
			layui.form.on('submit(login)', function(e){
				
				let url = '{:url("index/login")}';
				action_post_json(url, e.field, function(response){
					layer.msg(response.message);
					switch(response.errno){
						case 0 :
							setTimeout(function(){
								window.location.reload();
							}, 1000);
							break;
					};
				});
				
				return false;
			});
			
			$('img#verify').on('click', function(e){
			
				let url = '{:url("index/captcha")}';
				action_post_json(url, e.field, function(response){
					switch(response.errno){
						case 0 :
							$(e.currentTarget).attr('src', response.data.captcha);
							$('input[name=verify]').val('');
							break;
					};
				});
			});
		});
        
    </script>
</body>
</html>